﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

namespace WebApplication1
{
    /// <summary>
    /// API 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消注释以下行。 
    // [System.Web.Script.Services.ScriptService]
    public class API : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            try
            {
                return "Hello World";
            }
            catch(Exception e)
            {
                return e.Message;
            }
        }

        [WebMethod]
        public string Task1()
        {
            return "Task1";
        }

        [WebMethod]
        public void VoidTask()
        {
           
        }

        [WebMethod]
        public string Task3(string account, string name)
        {            
            try
            {
                return ReturnMsg(0, string.Format(" account : {0} , name : {1} ", account, name));
            }
            catch (Exception e)
            {
                return ReturnMsg(-1, e.Message);
            }
        }

        [WebMethod]
        public string Task4(string orderno, decimal money)
        {
            try
            {
                return ReturnMsg(0, string.Format(" orderno : {0} , money : {1} ", orderno, money));
            }
            catch (Exception e)
            {
                return ReturnMsg(-1, e.Message);
            }
        }

        [WebMethod]
        public string Task5(string orderno, decimal money)
        {
            return "Hi";
        }

        private string ReturnMsg(int code, string msg)
        {
            return code + "|" + msg;
        }
    }
}
